<template>
	<view>
		<view class="doctor-item" @click="toPage">
			<view class="img">
				<image v-if="doctorItem.headImg" :src="hostApi+doctorItem.headImg"></image>
				<image v-else src="/static/images/hospital/defaultDoctor.png"></image>
			</view>
			<view class="mar-0-10">
				<view>{{doctorItem.name}}</view>
				<view class="color-gray">{{doctorItem.jobTitle}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapGetters
	} from 'vuex'
	import {
		doctorSelect
	} from '../../api/doctor';
	export default {
		computed: {
			...mapGetters(['hostApi', "userInfo"])
		},
		props: {
			code: String
		},
		data() {
			return {
				doctorItem: {}
			}
		},
		mounted() {
			this.init()
		},
		methods: {
			init() {
				doctorSelect({
					code: this.code
				}).then(res => {
					console.log(res)
					this.doctorItem = res[0]
				})
			},
			toPage(){
				uni.navigateTo({
					url: '/pages/Introduce/doctor?code=' + this.code
				})
			}
		}
	}
</script>

<style scoped>
	.img {
		width: 40px;
		height: 40px;

		image {
			width: 100%;
			height: 100%;
			border-radius: 8rpx;
		}
	}
	.doctor-item{
		display: flex;
		justify-content: flex-start;
		margin: 10px;
	}
</style>